<template>
  <div class="mr-root co">
    <div v-if="k" class="not">
      你还没登录，先去登录一下吧
    </div>
    <div v-if="!k">
      <div class="collect">
        <div v-for="(u,index) in user.collect_topics">
          <div>
            <img :src="u.author.avatar_url" alt="">
            <span>{{u.last_reply_at | lasttime}}</span>
          </div>
          <p>{{u.title}} </p>
        </div>
      </div> 
    </div>
  </div>
</template>
<script>
  import TabBar from "../components/TabBar"
  export default {
    data() {
      return {
        k: true,
        user: {}
      }
    },
    components: {

    },
    created() {
      if (localStorage.getItem('accesstoken')) {
        this.k = false
        this.axios.get("http://www.vue-js.com/api/v1/user/" + localStorage.getItem('user'))
          .then(data => {
            //   console.log(data.data.data)
            this.user = data.data.data
            console.log(this.user)
          })
          .catch(err => {
            console.log(err)
          })
      } else {
        this.k = true
      }
    }
  }

</script>
<style scoped>
  .co {
    padding: 0 15px;
  }
  .collect{
    margin: 10px 0;
  }
  .collect span{
    float: right;
  }
  .collect img{
    width: 1rem;
  }
</style>
